/**
 * ...
 * >author		João Vítor de Souza
 */

package com.cupcakeengine.display 
{
	import flash.display.Sprite;
	import flash.errors.IllegalOperationError;
	import flash.events.Event;
	
	public class AbstractDisplay extends Sprite
	{
		// ___________________________________________________________________ CONSTANTS		
		
		// ___________________________________________________________________ CLASS PROPERTIES
		
		// ___________________________________________________________________ INSTANCE PROPERTIES
		
		// ___________________________________________________________________ GETTERS AND SETTERS
		
		// ___________________________________________________________________ CONSTRUCTOR		
		
		public function AbstractDisplay()
		{
			if (stage) {
				onAddedStage(null);
			} else {
				addEventListener(Event.ADDED_TO_STAGE, onAddedStage);
			}		
		}
		
		// ___________________________________________________________________ PUBLIC METHODS
		
		protected function init():void
		{
			throw new IllegalOperationError("Abstract method: must be overriden in a subclass");
		}
		
		// ___________________________________________________________________ PRIVATE METHODS
		
		// ___________________________________________________________________ EVENTS
		
		private function onAddedStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedStage);
			
			init();
		}
	}
}

